<?php

namespace app\index\service\payments;

use think\exception\ValidateException;

/**
 * 保证金账户
 * Class MarginPaymentService
 * @package app\index\service\payments
 */
class MarginPaymentService extends AbstractAccountPaymentService
{
    // 当前支付方式
    const PAYMETHOD = PAYMENT_MARGIN;

    /**
     * 支付失败处理
     * @param $direction
     * @param $memberId
     * @param $payMethod
     * @param $money
     * @param $memberBeforeMoney
     * @param $systemBeforeMoney
     * @param $errorCode
     * @return mixed|void
     */
    protected function payFailedHandle($direction, $memberId, $payMethod, $money, $memberBeforeMoney, $systemBeforeMoney, $errorCode)
    {
        $accountName = '保证金';

        if ($errorCode === static::ERROR_CODE_MEMBER_ACCOUNT_NOT_FOUND) {
            throw new ValidateException('您未开通' . $accountName . '账户，请联系客服');
        }

        if ($errorCode === static::ERROR_CODE_SYSTEM_ACCOUNT_NOT_FOUND) {
            throw new ValidateException('平台不支持' . $accountName . '支付，请联系客服');
        }

        if ($errorCode === static::ERROR_CODE_MEMBER_ACCOUNT_BALANCE_NOT_ENOUGH) {
            throw new ValidateException('您的' . $accountName . '不足，请充值后继续');
        }

    }
}
